import { createRouter, createWebHistory } from 'vue-router';

const routes = [
  {
    path: '/redEnvelope/:businessId(\\d+)/:activityId/:invite?',
    name: 'RedEnvelope',
    props: true,
    component: () => import(/* webpackChunkName: "RedEnvelope" */ '../views/RedEnvelope/RedEnvelope.vue'),
    meta: {
      title: '红包裂变',
      keepAlive: false,
    },
  },
  {
    path: '/redEnvelope/invite/:activityId',
    // path: 'inviteList',
    name: 'InviteList',
    props: true,
    component: () => import(/* webpackChunkName: "InviteList" */ '../views/RedEnvelope/InviteList.vue'),
    meta: {
      title: '邀请列表',
      keepAlive: false,
    },
  },
  {
    path: '/redEnvelope/packet/:activityId',
    // path: 'inviteList',
    name: 'PacketList',
    props: true,
    component: () => import(/* webpackChunkName: "PacketList" */ '../views/RedEnvelope/PacketList.vue'),
    meta: {
      title: '红包列表',
      keepAlive: false,
    },
  },
  {
    path: '/redEnvelope/feedback/:activityId',
    // path: 'feedback',
    name: 'Feedback',
    props: true,
    component: () => import(/* webpackChunkName: "Feedback" */ '../views/RedEnvelope/Feedback.vue'),
    meta: {
      title: '投诉',
      keepAlive: false,
    },
  },
  {
    path: '/redEnvelope/feedback/:activityId/option',
    // path: 'feedbackOption',
    name: 'FeedbackOption',
    props: true,
    component: () => import(/* webpackChunkName: "FeedbackOption" */ '../views/RedEnvelope/FeedbackOption.vue'),
    meta: {
      title: '投诉',
      keepAlive: false,
    },
  },
  {
    path: '/redEnvelope/feedback/:activityId/FeedbackSubmitted',
    // path: 'feedbackSubmitted',
    name: 'FeedbackSubmitted',
    props: true,
    component: () => import(/* webpackChunkName: "FeedbackSubmitted" */ '../views/RedEnvelope/FeedbackSubmitted.vue'),
    meta: {
      title: '投诉',
      keepAlive: false,
    },
  },
  {
    path: '/needKnow',
    name: 'NeedKnow',
    props: true,
    component: () => import(/* webpackChunkName: "FeedbackSubmitted" */ '../views/RedEnvelope/NeedKnow.vue'),
    meta: {
      title: '',
      keepAlive: false,
    },
  },
  {
    path: '/wxTest',
    name: 'WXTest',
    component: () => import(/* webpackChunkName: "WXTest" */ '../views/WXTest.vue'),
    meta: {
      title: '企业微信功能测试',
      keepAlive: false,
    },
  },
  {
    path: '/customerService',
    name: 'CustomerService',
    props: true,
    component: () => import(/* webpackChunkName: "DeployList" */ '../views/RedEnvelope/CustomerService.vue'),
    meta: {
      title: process.env.VUE_APP_NAME,
      keepAlive: false,
    },
  },
  {
    path: '/openInWxwork',
    name: 'OpenInWxwork',
    component: () => import(/* webpackChunkName: "OpenInWxwork" */ '../views/OpenInWxwork.vue'),
    meta: {
      title: 'h',
      keepAlive: false,
    },
  },
  {
    path: '/:pathMatch(.*)',
    name: 'error',
    component: () => import(/* webpackChunkName: "error" */ '../views/Error.vue'),
    meta: {
      title: '出错了',
      keepAlive: false,
    },
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

router.afterEach((to) => {
  // document.title = [...to.matched.map(({ meta }) => meta.title).filter((item) => item), process.env.VUE_APP_NAME].join(
  //   '-'
  // );
  document.title = to.meta.title;
});

export default router;
